package com.codingvip.scanner;

import java.util.Scanner;

/**
 * @Author Tony.Han
 * @Created at 2020/4/9 10:42 下午
 * Desc:
 */
public class RegTest {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int line = scanner.nextInt();
        scanner.nextLine();
        for (int i = 0; i < line; i++) {
            System.out.println(scanner.nextLine().
                    replaceAll("(.)\\1+", "$1$1")
                    .replaceAll("(.)\\1(.)\\2", "$1$1$2"));
        }
    }
}
